package com.longge;

import java.util.Comparator;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-23 01:17
 */
public class SortSentence {
    public String sortSentence(String s) {

        String[] split = s.split(" ");

        return Stream.of(split).sorted(Comparator.comparing(s1 -> s1.substring(s1.length() - 1))).map(s1 -> s1.substring(0, s1.length() - 1)).collect(Collectors.joining(" "));
    }
}